package com.example.pojo;

public class Comment {

    private int commentId;       // 评论ID（主键）
    private String userId;     // 评论用户
    private int newsId;       // 关联的新闻ID（关键属性，未删除！）
    private String commentContent; // 评论内容
    private String commentDate;  // 评论时间
    private int likeNum;         // 点赞数
    private Boolean isLiked;     // 当前用户是否已点赞（新增字段）

    // 1. 含所有字段的完整构造方法（包含 newsId）
    public Comment(int commentId, String userId, int newsId,
                   String commentContent, String commentDate, int likeNum, Boolean isLiked) {
        this.commentId = commentId;
        this.userId = userId;
        this.newsId = newsId; // 保留 newsId 赋值
        this.commentContent = commentContent;
        this.commentDate = commentDate;
        this.likeNum = likeNum;
        this.isLiked = isLiked;
    }

    // 2. 兼容 Dao 层查询的构造方法（之前漏了 newsId，现在补全）
    public Comment(int commentId, String userId, int newsId,
                   String commentContent, String commentDate, int likeNum) {
        this.commentId = commentId;
        this.userId = userId;
        this.newsId = newsId; // 关键：给 newsId 赋值
        this.commentContent = commentContent;
        this.commentDate = commentDate;
        this.likeNum = likeNum;
        this.isLiked = false; // 默认未点赞
    }

    // 3. 所有属性的 getter/setter（必须完整，否则赋值/序列化失败）
    public int getCommentId() { return commentId; }
    public void setCommentId(int commentId) { this.commentId = commentId; }



    // newsId 的 getter/setter（核心，之前没写全）
    public int getNewsId() { return newsId; }
    public void setNewsId(int newsId) { this.newsId = newsId; }

    public String getCommentContent() { return commentContent; }
    public void setCommentContent(String commentContent) { this.commentContent = commentContent; }

    public String getCommentDate() { return commentDate; }
    public void setCommentDate(String commentDate) { this.commentDate = commentDate; }

    public int getLikeNum() { return likeNum; }
    public void setLikeNum(int likeNum) { this.likeNum = likeNum; }

    public Boolean getIsLiked() { return isLiked; }
    public void setIsLiked(Boolean isLiked) { this.isLiked = isLiked; }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Boolean getLiked() {
        return isLiked;
    }

    public void setLiked(Boolean liked) {
        isLiked = liked;
    }
}